package Offer2017;

import java.util.Arrays;

/**
 * Created by 雷文康 on 2018/1/6.
 */
public class Test44 {
    public static void main(String[] args) {
        int[] array = {4, 0, 3, 5, 7};
        System.out.println(isContinuous(array));
    }

    public static boolean isContinuous(int[] array) {
        if (array == null || array.length == 0) {
            return false;
        }
        Arrays.sort(array);
        int count0 = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i] == 0) {
                count0++;
            }
        }
        int gap = 0;
        for (int i = 0; i < array.length - 1; i++) {
            if (array[i] == 0) {
                continue;
            }
            if (array[i + 1] == array[i]) {
                return false;
            }
            gap += array[i + 1] - array[i] - 1;
        }
        if (count0 >= gap) {
            return true;
        }
        return false;
    }
}
